<div>
    <div class='login_div'>
      <?php if($barber){?>
        <form  action='/home/barber/update' method="post">
      <?php }else{?>
        <form  action='/home/barber/submit' method="post" id='form'>
      <?php }?>
            <input type='hidden' name='id' value="<?php echo $barber['id']?>">
            <div class='form-group row'>
                <label for="exampleInputName2">所属门店:</label>
                <select name='store'>
                    <option>请选择门店</option>
                    <?php foreach($_store as $v){?>
                    <option value='<?php echo $v['id'];?>' <?php if($v['id']==$barber['store_id']){echo "selected='selected'";}?>><?php echo $v['name'];?></option>
                    <?php }?>
                </select>
            </div>
            <div class='form-group row'>
                <label for="exampleInputName2">姓名:</label>
                <input type="text" class="form-control" name='name' value="<?php if($barber){echo $barber['name'];}else{echo '';}?>" placeholder=""/>
            </div>
            <div class='form-group row'>
                <label for="exampleInputName2">性别:</label>
                <?php if(empty($barber) || $barber['sex']==0){?>
                    <input type="radio" name="sex" value="0" checked> 男
                    <input type="radio" name="sex" value="1"> 女 
                <?php }else{?>
                    <input type="radio" name="sex" value="0" > 男
                    <input type="radio" name="sex" value="1" checked> 女 
                <?php } ?>    
            </div>
            <div class='form-group row'>
                <label for="exampleInputName2">头像:</label>
                <?php if($barber['id']>0){?>
                <input type='hidden'  class="form-control" name='photo' id='photo' value="<?php echo $barber['photo'];?>">
                <div style="height: 30rem;width:30rem;margin:2rem auto">
                <img src="<?php echo $barber['photo'];?>" class="form-control" style="width:100%;height: 100%;border-radius:50%;overflow:hidden;" id="photo_img" alt=''/>
                </div>
                <?php }else{?>
                <div style="height: 30rem;width:30rem;margin:2rem auto">
                <input type='hidden'  class="form-control" name='photo' id='photo' value='/public/images/tou.png'>
                <img src="/public/images/tou.png" class="form-control" style="width:100%;height: 100%;border-radius:50%;overflow:hidden;" id="photo_img"/>
                </div>
                <?php }?>
                <iframe src="/home/barber/img" frameborder="no" border="0" scrolling='no' style="width:25rem;height: 4rem;padding-top: 1rem" ></iframe>
            </div>
            <div class='form-group row'>
                <label for="exampleInputName2">账号(发型师手机号):</label>
                <?php if(!empty($barber)){?>
                <input type="text" class="form-control" name='mobile' value="<?php if($barber){echo $barber['mobile'];}?>" disabled="disabled" />
                <?php }else{ ?>
                <input type="text" class="form-control" name='mobile' value=""  />
                <?php } ?>
            </div>
            <div class='form-group row'>
                <label for="exampleInputName2">级别:</label>
                <select name='level'>
                 <?php foreach($level as $v){
                            if($v['name']==$barber['level']){
                                echo "<option value='".$v['name']." 'selected = 'selected'>".$v['name']."</option>";
                                continue; 
                            }
                            echo "<option value='".$v['name']."'>".$v['name']."</option>";
                        } 
                  ?>
                </select>
            </div>
            <div class="form-group login_sub">
            <?php if($barber){?>
                <input type="submit" class="btn btn-info" name="submit" value="确认修改">
             <?php }else{?>   
                <input type="submit" class="btn btn-info" name="submit" value="添加">
                <?php }?>
            </div>
        </form>
    </div>
</div>

<script type='text/javascript'>
    $(document).ready(function () {
        $("#form").validate({
            rules: {
                store:{
                    required: true,
                    min:1
                },
                name: {
                    required: true,
                },
                sex: {
                    required: true,
                },
                level: {
                    required: true,
                },
                mobile: {
                    required: true,
                    number: true,
                    mobile: true
                },
                
            },
            messages: {
                store:{
                    required: '请选择店铺',
                    min: '请选择店铺'
                },
                name: {
                    required: '请输入姓名',
                },
                sex: {
                    required: '请选择性别',
                },
                level: {
                    required: '请输入级别',
                },
                mobile: {
                    required: '请输入手机号',
                    number: '请输入手机号',
                    mobile: '请输入手机号'
                },
            }
        });
  jQuery.validator.addMethod("mobile", function (value, element) {
            var length = value.length;
            var mobile = /^(((1[1-9]{1}[0-9]{1})|(15[0-9]{1}))+\d{8})$/
            return this.optional(element) || (length == 11 && mobile.test(value));
        }, "手机号码格式错误");
    });
</script>